define(function(require, exports){
	var pubjs = require('pubjs');
	var grid  = require('@base/highGrid');
	var $     = require('jquery');
	var dspUtil = require('dspUtil');

	var HighGrid = grid.base.extend({
		init: function(config){
			config = pubjs.conf(config, {
				'cols': [
					{name:'_id',text:"ID",width:150,align:'center'}
				],
				'metrics': dspUtil.shield_price([
					{name:"Name",text:LANG('广告位'),align:"left",width:410,render: 'renderName'},
					{name:"Size",text:LANG("尺寸"),render:'renderPixelSize'},
					'AdvisePrice',
					'request_num',
					'click_rate',
					{name:"AllowMaterialNames",text:LANG("素材要求"),align:"center"}
				]),
				'hasTab': false,
				'hasBatch': false,
				'hasAmount': false,
				'hasSwitch': false,
				'hasSubGrid': false,
				'eventDataLoad': true,
				'gridName': 'mediaReport',
				'url': 'spot/mediaReport',
				'param': {
					'noAmount': true
					,'isRTB': true
					,'mongoField': ['Name', 'Size', 'AllowMaterialNames', 'AdvisePrice', 'PageUrl', 'AdxId']
				},
				'reqType': 'websocket'

				// 'pager': {'size':8, 'showSizeTypes':0} @todo 这个参数需要么？
			});
			this.Super('init', arguments);
		},
		renderName: function(i, val, data, con){
			val = val || '-';
			var hasIcon = data.SystemDeduct > 0;
			var ret = [];
			var width = con.width - 35;
			if(hasIcon) {
				ret.push('<em class="costPrice"></em>');
			}
			if(data.PageUrl) {
				ret.push('<a style="width: ' + width + 'px" class="uk-text-truncate tl fl" target="_blank" href="'+ data.PageUrl +'" title="'+val+'">'+val+'</a>');
			}
			else {
				ret.push('<div style="width: ' + width + 'px" class="uk-text-truncate tl fl" title="'+val+'">'+val+'</div>');
			}

			return $(ret.join(''));
		}
	});
	exports.base = HighGrid

});